﻿//-----------------------------------------------------------------------
// <copyright file="StringExtensionsUnitTest.cs" company="CodePlex">
//     Copyright (c) Doug Holland, CodePlex. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace CodePlex.Diagnostics
{
    using System;
    
    using System.Collections;
    using System.Collections.Generic;

    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis;

    using System.Security;
    using System.Security.Principal;

    using System.ServiceModel;

    using System.Xml.Linq;

    using CodePlex.Diagnostics.Contracts;
    using CodePlex.Diagnostics.Services;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// Provides unit tests for the <see cref="T:CodePlex.Diagnostics.StringExtensions"/> class.
    /// </summary>
    [TestClass]
    public sealed class StringExtensionsUnitTest
    {
        #region public StringExtensionsUnitTest()

        /// <summary>
        /// Initializes a new instance of the <see cref="T:StringExtensionsUnitTest"/> class.
        /// </summary>
        public StringExtensionsUnitTest()
        {
        }

        #endregion

        #region public TestContext TestContext

        /// <summary>
        /// Gets or sets the test context which provides information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext
        {
            get;
            set;
        }

        #endregion

        #region public void Log()

        /// <summary>
        /// Logs the message and ensures that the appropriate publication Id is returned from the service.
        /// </summary>
        [TestMethod]
        public void Log()
        {
            string quote = "we seek only the day, when nation shall not lift up sword against nation, neither shall they learn war anymore.";
            
            Guid publicationId = quote.Log(LoggingPriority.Medium, LoggingType.Information);
            
            Assert.AreNotEqual<Guid>(publicationId, Guid.Empty, "invalid publication id.");
        }

        #endregion

        #region public void LogDictionary()

        /// <summary>
        /// Logs the message and ensures that the appropriate publication Id is returned from the service.
        /// </summary>
        [TestMethod]
        public void LogDictionary()
        {
            string quote = "we seek only the day, when nation shall not lift up sword against nation, neither shall they learn war anymore.";

            IIdentity identity = WindowsIdentity.GetCurrent() as IIdentity;

            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            dictionary.Add("System.Type", "System.String");

            XElement element = XElement.Parse("<?xml version=\"1.0\" encoding=\"utf-8\"?><xelement>unit test</xelement>");

            quote.Log(LoggingPriority.Medium, LoggingType.Information, dictionary, element, identity);
        }

        #endregion
    }
}
